﻿

function addgood(el,gid)
{
    var parent = $(el).parent().parent().parent();
    var img = {}
    img.src = $(el).attr("imgsrc");
    img.width = $(el).attr("img-data-width");
    img.height = $(el).attr("img-data-height");

    var name = $(el).attr("title");
    var sellprice = $(el).attr("sellprice");
    var right = window.parent.frames["frame_right"][0].contentDocument;
    var goods = $(right).find("#goods");//$(right).find("#goods").append(html);
    var isexist = goods.find("#" + gid);
    if (isexist.length < 1) {
       var tr= goods.find("tr");
        var html = formatHtml(img, name, sellprice, gid, tr.length);
        goods.append(html);
    }
   
    

    
    //var goodarray = $(right).find("#ctl00_cph_main_goodarray");
    //var hdnarray = $(goodarray).val();
    //$(goodarray).val(hdnarray + "@#@" + gid + "," + sellprice.replace("¥", "") + "@#@");
   
}

function formatHtml(img, name, sellprice,gid,num)
{
    var html = "";
    html += ' <tr id="' + gid + '">';
    html += '   <td><span class="shownum">' + (parseInt(num)+1) + '</span></td>';
    html += '  <td><img class="list_pic" src="' + img.src + '"  data-width="' + img.width + '" data-height="' + img.height + '" onerror="$(this).hide();" style="display: none;"/><div class="intd">' + name + ' </div></td>';
    html += '   <td>' + sellprice + '</td>';
    html += '  <td><input  type="text" class="gbsellprice" id="' + gid + '" value="' + sellprice.replace("¥", "") + '"/></td>';
    html += '   <td><a href="javascript:;" class="delgood">删除</a></td>';
    html += '  </tr>';
    return html;
}

